<template>
	<el-table
	    :data="batchTableData"
	    style="width: 100%"
      height=100%
      v-loading="loading"
      element-loading-text="数据正在加载中..."
      :header-cell-style="{background:'#eef1f6',color:'#606266'}"
		>

	    <el-table-column
	      label="批次名称"
		  align=center
	      width="180">
	      <template slot-scope="scope">
	        <span style="margin-left: 10px">{{ scope.row.batchName }}</span>
	      </template>
	    </el-table-column>
		<el-table-column
		  label="学院评审开始日期"
		  align=center
		 >
		  <template slot-scope="scope">
		    <i class="el-icon-time"></i>
		    <span style="margin-left: 10px">{{ scope.row.phaseDepartmentStart }}</span>
		  </template>
		</el-table-column>
		<el-table-column
		  label="学院评审结束日期"
		  align=center
		  >
		  <template slot-scope="scope">
		    <i class="el-icon-time"></i>
		    <span style="margin-left: 10px">{{ scope.row.phaseDepartmentEnd }}</span>
		  </template>
		</el-table-column>
		</el-table-column>
	    <el-table-column
	      label="批次类别"
		  align=center
	      >
	      <template slot-scope="scope">
	        <span >{{ scope.row.levelName }}</span>
	      </template>
	    </el-table-column>
	    <el-table-column
		align=center
		label="操作">
	      <template slot-scope="scope">
	        <el-button
	          size="mini"
			  type="success"
	          @click="enterBatch(scope.$index, scope.row)">进入</el-button>
	      </template>
	    </el-table-column>
	  </el-table>

</template>

<script>
	export default {
		mounted() {
      this.teacherinfo = this.$store.state.info
			this.getAllData()
			this.getNowDate()

      console.log(this.$store.state.info)
		},
	    data() {
	      return {
       teacherinfo:'',
			 //batch表数据
	     batchTableData:[],
        //yyyy-mm-dd型日期
        nowDate:'',
        //加载状态
        loading:true
	      }
	    },
	    methods: {
	      enterBatch(index, row) {
			this.$router.push({path:'/depProjectAudit',query:{batch_id:row.batchId}})
	        console.log(index, row);
	      },
		  //获得数据Axios
		  getAllData(){
			  this.$api.batch.getBatchByDepId({
          depId:this.teacherinfo.bmbh
        })
			  .then((response)=>{
				  console.log(response)
				  this.batchTableData=response.data.data.filter((item)=>{
					return  new Date(this.nowDate) >=  Date.parse(item.phaseDepartmentStart)
					&& new Date(this.nowDate) <= Date.parse(item.phaseDepartmentEnd) && item.status==0
					console.log(this.batchTableData)
				  })
				  this.loading=false
			  })
		  }
		  ,
		  //得到当前日期
		  getNowDate(){
		    var nowDate = new Date();
		    var year = nowDate.getFullYear();
		    var month = nowDate.getMonth() + 1 < 10 ? "0" + (nowDate.getMonth() + 1): nowDate.getMonth() + 1;
		    var day = nowDate.getDate() < 10 ? "0" + nowDate.getDate() : nowDate
		     .getDate();
		    var dateStr = year + "-" + month + "-" + day;
		    this.nowDate=dateStr
		  },
	    }
	  }
</script>

<style scoped>

</style>
